﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Utility.BehaviourTree
{
	public class WaitNode : LeafNode
	{
		float waitTime = 0;
		float targetTime = -1;

		public WaitNode (float waitTime)
		{
			this.waitTime = waitTime < 0 ? 0 : waitTime;
		}

		protected override bool OnStart ()
		{
			targetTime = DataBoard.Time + waitTime;
			return true;
		}

		protected override Status OnUpdate ()
		{
			return DataBoard.Time >= targetTime ? Status.Success : Status.Running;
		}

		protected override void OnReset ()
		{
			base.OnReset ();
			targetTime = -1;
		}
	}
}